/-imports
/-storage ...
/-storage/attached ...
/-storage/attached/api
LocalStorageStorage.ts
WebSQLStorage.ts
/-typings
stringUtils.ts
teapo.html
48
            });
49
        },
50
        sqlError=> {
51
          callback(WebSQLStorage.wrapSQLError(sqlError), null);
52
        });
53
 
54
    }
55
 
56
  }
57
  
58
  export module WebSQLStorage {
59
 
60
    export class LoadStorage implements attached.LoadStorage {
61
 
62
      constructor(
63
        public editedUTC: number,
64
        private _db: Database) {
65
      }
66
 
67
      load(recipient: LoadStorageRecipient) {
68
 
69
        if (typeof this.editedUTC !== 'number'){
70
          recipient.completed(new UpdateStorage(this._db));
71
          return;
72
        }
73
 
74
        this._db.readTransaction(
75
          transaction => {
76
            transaction.executeSql(
77
              'SELECT tbl_name  from sqlite_master WHERE type=\'table\'',
78
              [],
79
              (transaction, result) => {
80
                this._processTableNames(transaction, result, recipient);
81
              },
82
              (transaction, sqlError) =>
83
                recipient.completed(new UpdateStorage(this._db)));
84
          },
85
          sqlError => recipient.failed(wrapSQLError(sqlError)));
86
      }
87
 
88
      migrate(filesByName: { [name: string]: { [name: string]: string; }; }, callback: (error: Error, updater: attached.UpdateStorage) => void) {
89
 
90
        this._db.transaction(
91
          transaction=> {
92
 
93
            this._dropAllTables(transaction);
94
 
95
            var validTableNames: { [name: string]: boolean; } = {};
96
 
97
            for (var file in filesByName) if (filesByName.hasOwnProperty(file)) {
98
              var properties = filesByName[file];
99
              for (var propertyName in properties) if (properties.hasOwnProperty(propertyName)) {
100
                var value = properties[propertyName];
101
 
102
                
103
              }
104
            }
105
            
106
          },
107
          sqlError => callback(wrapSQLError(error), null));
108
 
109
      }
110
 
111
      private _dropAllTables(transaction: SQLTransaction, callback: (error: SQLError) => void) { 
112
      }
113
 
114
      private _processTableNames(transaction: SQLTransaction, result: SQLResultSet, recipient: LoadStorageRecipient) {
115
 
116
        var length = result && result.rows ? result.rows.length : 0;
117
 
118
        var ftab = this._extractFileNames(result);
119
        if (!ftab.length){
120
          recipient.completed(new UpdateStorage(this._db));
121
          return;
122
        }
123
 
124
        var anyError = false;
125
        var reportedFileCount = 0;
126
        ftab.forEach(ft=> {
127
          transaction.executeSql(